<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*" session="true"%>
<%@ page import = "pe.com.deuda.bd.dao.ConsultaDAO"%>
<%@ page import = "pe.com.deuda.bd.model.Deudor"%>
<%@ page import = "java.util.ArrayList"%>
<%@ page import = "java.util.List"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <center>
        <%
        Deudor deudor=new Deudor();
        deudor.setApmaterno(request.getParameter("txMaterno"));
        deudor.setAppaterno(request.getParameter("txPaterno"));
        if (request.getParameter("txDepartamento").toString().length()>0 ){
            deudor.setDepartamento(request.getParameter("txDepartamento"));
        }
        else{
            deudor.setDepartamento(" ");
        }
        if (request.getParameter("txDescripcion").toString().length()>0 ){
            deudor.setDescripcion(request.getParameter("txDescripcion"));
        }
        else {deudor.setDescripcion(" ");}
        if (request.getParameter("txDireccion").toString().length()>0 ){
            deudor.setDireccion(request.getParameter("txDireccion"));
        }
        else{deudor.setDireccion(" "); }
        if (request.getParameter("txDistrito").toString().length()>0){
            deudor.setDistrito(request.getParameter("txDistrito"));
        }
        else {deudor.setDistrito(" ");}
        if (request.getParameter("txDNI").toString().length()>0){
            deudor.setDni(request.getParameter("txDNI"));
        }
        else{deudor.setDni(" ");}
        deudor.setMail(request.getParameter("txMail"));
        deudor.setMoneda(request.getParameter("txMoneda"));
        deudor.setMonto(request.getParameter("txMonto"));
        deudor.setMotivo(request.getParameter("txMotivo"));
        deudor.setNombre(request.getParameter("txNombre"));
        if (request.getParameter("txProvincia").toString().length()>0){
            deudor.setProvincia(request.getParameter("txProvincia"));
        }
        else{deudor.setProvincia(" ");}
        if (request.getParameter("txSustento").toString().length()>0){
            deudor.setSustento(request.getParameter("txSustento"));
         }
        else {deudor.setSustento(" ");}
        deudor.setTelefono(request.getParameter("txTelefono"));
        deudor.setUsuario(session.getAttribute("usuario").toString());
        ConsultaDAO dao=new ConsultaDAO();
        String r=dao.RegistraDeudor(deudor);
        if (r.equals("OK")){
        %>
        <p>Registro éxitoso</p>
        <%}
        else{
        %>
        <p><%=r%></p>
        <%}%>
        <br><br>
        <a href="../formularios/BuscaDeudor.jsp" target="_self">Ir a búsqueda</a>
        </center>
    </body>
</html>
